package com.hotdog.aspect;
import com.hotdog.feign.SysTemLogInfoFeign;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
 * 对登陆进行日志记录
 * @author 郭鲁政
 */
@Slf4j
@Aspect
@Component
public class LogAspect {
@Autowired
private SysTemLogInfoFeign sysTemLogInfoFeign;

    /**
     * 使用aop的around方法
     * @param joinPoint
     * @return
     * @throws Throwable
     */
    @Around("execution(* com.hotdog.service.LoginServiceImpl.loadUserByUsername(..))")
    public Object test3(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();
        String s = String.valueOf(args[0]);

        Object proceed = joinPoint.proceed(args);

        sysTemLogInfoFeign.saveLogInfo(s,"login");
        return proceed;
    }
}
